package com.bit.demo3;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2022-11-14
 * Time: 20:55
 */
class Animal {
    public String name;
    public int age;
    protected int count;

    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(name+"eat()");
//        System.out.println(count);
    }
}

class Dog extends Animal {
    public Dog(String name,int age) {
        super(name,age);
    }
    @Override
    public void eat() {
        System.out.println(name + " 狼吞虎咽eat()");
    }
}
class Bird extends Animal {
    public String wing;
    public Bird(String name,int age,String wing) {
        super(name,age);
        this.wing = wing;
    }
    public  void fly() {
        System.out.println(name + "fly()" + age);
    }
}

public class Test {


    //动态绑定
    public static void main(String[] args) {

        Animal animal = new Dog("haha",19);//父类引用  引用  子类对象
        animal.eat();
    }
    public static void func(Animal animal) {

    }
    public static Animal func2() {
        Dog dog = new Dog("haha",19);
        return dog;
    }
    public static void main1(String[] args) {
/*        Dog dog = new Dog("haha",19);
        Animal animal = dog;*/
        Animal animal = new Dog("haha",19);//父类引用  引用  子类对象
        Dog dog = new Dog("haha",19);
        func(dog);
    }

}
